<?php
############## DIT STUK CODE ZORGT ERVOOR DAT JE ALS ADMIN INGELOGD MOET ZIJN OM DE PAGINA TE KUNNEN ZIEN ##############
    //Start de sessie
    session_start();

    //Load de benodigde bestanden
    require_once("includes/auth.php");
########################################################################################################################
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Klant toevoegen</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <link type="text/css" href="../css/pagination.css" rel="stylesheet" />
  <link rel="stylesheet" href="../css/reset.css" type="text/css" />
  <link rel="stylesheet" href="../css/960.css" type="text/css" />
  <link rel="stylesheet" href="../css/text.css" type="text/css" />
  <link type="text/css" href="../css/tablesorter.css" rel="stylesheet" />
  <link type="text/css" href="../css/sunny/jquery-ui-1.8.custom.css" rel="stylesheet" />
  <link type="text/css" href="../css/jquery.autocomplete.css" rel="stylesheet" />
  <link type="text/css" href="../css/style.css" rel="stylesheet" />
  <link type="text/css" href="../css/accmenu.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery-1.4.2.min.js">
</script>
<script type="text/javascript" src="../js/jquery-ui-1.8.custom.min.js">
</script>
<script type="text/javascript" src="../js/jquery.tablesorter.js">
</script>
<script type="text/javascript" src="../js/jquery.autocomplete.min.js">
</script>
<script type="text/javascript" src="../js/menu.js">
</script>


</head>

<body>
  <div class="container_12">
    <div id="header" class="grid_12">

    </div>

    <div class="clear"></div>

    <div class="grid_12 spacer"></div>

    <div class="clear"></div>

    <div id="menu" class="grid_2">

        <?php
        include_once 'temp/menu_filler.php';
        ?>


    </div>

    <div id="adminarea" class="grid_10">
        <div id="tableholder">

                <?php

                // Connects to your Database
                include 'includes/connect.php';

                if (!isset($_POST['submit'])) // if page is not submitted to itself echo the form
                {
                ?>
                    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
                    Voornaam: <input type="text" name="voornaam" /><br />
                    Tussenvoegsel: <input type="text" name="tussenvoegsel" /><br />
                    Achternaam: <input type="text" name="achternaam" /><br />
                    Postcode: <input type="text" name="postcode" /><br />
                    Huisnummer: <input type="text" name="huisnummer" /><br />
                    Geslacht: <input type="radio" name="geslacht" value="M" />M<input type="radio" name="geslacht" value="V" />V<input type="radio" name="geslacht" value="O" />O<br />
                    Telefoonnummer: <input type="text" name="telefoonnr" /><br />
                    E-mailadres: <input type="text" name="email" /><br />
                    <input type="submit" name="submit" value="toevoegen">
                    </form>

                <?php
                }
                else
                {
                // Max productid zoeken
                $result = mysql_query("SELECT max(klantid) FROM klant")
                or die(mysql_error());
                $row = mysql_fetch_array( $result );
                $id=$row[0]+1;



                $sql="INSERT INTO klant (klantid, voornaam, tussenvoegsel, achternaam, postcode, huisnummer, geslacht, telefoonnr, email)
                VALUES
                ('$id','$_POST[voornaam]','$_POST[tussenvoegsel]','$_POST[achternaam]','$_POST[postcode]','$_POST[huisnummer]','$_POST[geslacht]','$_POST[telefoonnr]','$_POST[email]')";

                if (!mysql_query($sql))
                  {
                  die('Error: ' . mysql_error());
                  }
                echo "Nieuwe klant toegevoegd!";
                echo "<br />";



                }

                ?>

        </div>
    </div>

    <div class="clear"></div>

    <div class="grid_12 spacer"></div>

    <div class="clear"></div>
</div>
</body>
</html>